package com.hegongda.service.impl;

import com.hegongda.bean.OrderItemView;
import com.hegongda.bean.Orders;
import com.hegongda.bean.Poster;
import com.hegongda.dao.PosterDao;
import com.hegongda.service.PosterService;
import com.hegongda.utils.BeanFactory;
import com.hegongda.utils.JdbcUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;
import java.util.UUID;

public class PosterServiceImpl implements PosterService {
    private PosterDao pd = BeanFactory.newInstance(PosterDao.class);
    @Override
    public Poster getOnePoster(String id) {
        Poster onePoster = null;
        try {
            onePoster = pd.getOnePoster(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return onePoster;
    }

    @Override
    public int addPoster(String pid, String path) {
        try {
            int i = pd.addPoster(pid, path, UUID.randomUUID().toString().replace("-",""));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int EditPoster(String id,String path){
        int i = 0;
        try {
            i = pd.EditPoster(id, path);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return i;
    }

    @Override
    public List<Poster> showAll() {
        List<Poster> posters = null;
        try {
            posters = pd.showAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return posters;
    }

    @Override
    public int del(String id) {
        int i = 0;
        try {
            i = pd.del(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return i;
    }
}
